package com.qf.listener;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

import java.time.Duration;

@Component
public class KafkaConsumer1 {

    @KafkaListener(topics = "test")
    public void con1(ConsumerRecord<String,String> record/*, Acknowledgment ack*/){
        String key = record.key();
        String value = record.value();
        int partition = record.partition();
        long offset = record.offset();


        System.out.println("key:" + key +"--value:"+value +"--partition:"+partition +"--offset:"+offset);

        /*//执行成功，手动上报点位
        ack.acknowledge();
        //执行失败，不上报点位
        ack.nack(Duration.ZERO);*/
    }
}
